<?php
class Mincoding_VendorConnect_Model_Attribute_Source_Catalog_Product_Contractids extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{
	public function getAllOptions()
    {
        if (!$this->_options) {
            $this->_options = array();
            
            $collection = Mage::getModel('vendorconnect/contract')->getCollection()
                //->addFilter('main_table.is_active',1)
                ->setOrder("main_table.created_time","DESC");
            $collection->getSelect()->join( 
                array('vendors'=>$collection->getResource()->getTable('vendorconnect/vendors')),
                'main_table.vendor_id=vendors.id',
                array('vendor_name' => 'vendors.name')
             );
            
            foreach ( $collection as $vendor )
            {
                array_push(
                    $this->_options,array(
                        'value' =>$vendor->getId(),
                        'label' => '#' . $vendor->getId() . '-' . $vendor->getData('vendor_name')
                    )
                );  
              
            }
            
            //array_unshift($this->_options, array('value'=>'', 'label'=>Mage::helper('catalog')->__('Select ...')));
        }
        
        return $this->_options;
    }
}
